import Vue from 'vue'
import { loadType, Loading } from '.'

export function createLoading(props: Omit<loadType, 'btn'>) {
    const div = document.createElement('div')
    document.body.appendChild(div)

    return new Vue({
        el: div,
        mounted() {
            ;(this.$refs.loading as any).open()
        },
        methods: {
            close() {
                ;(this.$refs.loading as any).cancel()
            }
        },
        render() {
            return <Loading ref="loading" {...{ props }} />
        }
    })
}
